﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;

namespace MyWPF.Models.SQL
{
    public class MySqlHelper : ISql
    {
        

        public void LoadSQL(SqlContext sql)
        {
            // 设置连接字符串
            string connString = "server="+ sql.Server + ";user="+ sql.User + ";password=" + sql.Password;

            // 创建数据库连接对象
            MySqlConnection conn = new MySqlConnection(connString);

            // 打开连接
            conn.Open();

            // 创建数据库命令对象
            MySqlCommand cmd = new MySqlCommand();

            // 设置命令对象的连接
            cmd.Connection = conn;

            // 设置要执行的命令
            cmd.CommandText = "CREATE DATABASE mydatabase";

            // 执行命令
            cmd.ExecuteNonQuery();

            // 关闭连接
            conn.Close();
        }

        public void AddTable(TableContext table)
        {
            throw new NotImplementedException();
        }
    }
}
